
//
//  YDMineNotiView.m
//  PeiZiWangBei
//
//  Created by 巨彦新 on 2018/1/18.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDMineNotiView.h"


@interface YDMineNotiView()

/**
 icon
 */
@property (nonatomic, strong)UIImageView *icon;


/**
 红点
 */
@property (nonatomic, strong)UIView *redPoint;
@end

@implementation YDMineNotiView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.userInteractionEnabled = YES;
        [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]];
        [self icon];
        [self redPoint];
    }
    return self;
}


- (void)showRedPoint
{
    _redPoint.hidden = NO;
}


-(void)hideRedPoint
{

    _redPoint.hidden = YES;
   
}
-(void)setIsHide:(BOOL)isHide
{
    _redPoint.hidden = isHide;
}
- (void)tap:(UITapGestureRecognizer *)tap
{
    if (self.clickBack) {
        self.clickBack();
    }
}


-(UIImageView *)icon
{
    if (_icon == nil) {
        _icon = [UIImageView new];
        _icon.image = [UIImage imageNamed:@"wd-xiaoxi"];
        [self addSubview:_icon];
        [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(self);
        }];
        
    }
    return _icon;
}


-(UIView *)redPoint
{
    if (_redPoint ==nil) {
        _redPoint = [UIView new];
        _redPoint.backgroundColor = [UIColor whiteColor];
        _redPoint.layer.cornerRadius = 4;
        _redPoint.layer.masksToBounds = YES;
        [self addSubview:_redPoint];
        [_redPoint mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_icon.mas_right).offset(-2);
            make.top.equalTo(_icon.mas_top);
            make.width.height.equalTo(@8);
        }];
        
    }
    return _redPoint;
}
@end
